
 //6.定义一个名为Vehicles交通工具 的基类
 //该类中应包含String类型的成员属性brand 商标 和color 颜色
 //还应包含成员方法run 行驶在控制台显示“我已经开动了”和showInfo显示信息在控制台显示商标和颜色
 //并编写构造方法初始化其成员属性。编写Car 小汽车 类继承于Vehicles类
 //增加int型成员属性seats 座位 还应增加成员方法showCar 在控制台显示小汽车的信息 并编写构造方法。
 //编写Truck 卡车 类继承于Vehicles类 增加float型成员属性load 载重
 //还应增加成员方法showTruck 在控制台显示卡车的信息 并编写构造方法。
 //在main方法中测试以上各类。


public class VehiclesShow_06 {
    public static void main(String[] args) {
        Vehicles vehicles = new Vehicles("品牌", "颜色");
        vehicles.run();
        vehicles.showInfo();
        Car car = new Car("兰博基尼", "红色", 6);
        car.showCar();
        Truck truck = new Truck("东方雪铁龙", "白色", 12);
        truck.showTruck();
    }
}

class Vehicles {
    public String brand;
    public String color;

    public Vehicles() {
        super();
        // TODO 自动生成的构造函数存根
    }

    public Vehicles(String brand, String color) {
        super();
        this.brand = brand;
        this.color = color;
    }

    public void run() {
        System.out.println("我已经开动了！");
    }

    public void showInfo() {
        System.out.println("[ brand: " + brand + ", color: " + color + " ]");
    }
}

class Car extends Vehicles {
    public int seats;

    public Car() {
        super();
    }

    public Car(String brand, String color, int seats) {
        super(brand, color);
        this.seats = seats;
    }

    public void showCar() {
        System.out.println("[ brand: " + brand + ", color: " + color + ", seats: " + seats + " ]");
    }
}

class Truck extends Vehicles {
    public float load;

    public Truck() {
        super();
    }

    public Truck(String brand, String color, float load) {
        super(brand, color);
        this.load = load;
    }

    public void showTruck() {
        System.out.println("[ brand: " + brand + ", color: " + color + ", seats: " + load + " ]");
    }
}
